export default class Food{
    element:HTMLElement;
    constructor(){
        // @ts-ignore
        this.element = document.querySelector('.food');
    }

    get X(){
        return this.element.offsetLeft;
    }

    get Y(){
        return this.element.offsetTop;
    }

    //随机生成
    refreshPosition(){
        //内容范围是0-290
        const top = (Math.floor(Math.random()*29) + 1)*10;
        const left =(Math.floor(Math.random()*29 ) + 1)*10;
        this.element.style.top = top+'px';
        this.element.style.left =left+'px' ;

        console.log(`top:${top},left:${left}`)
    }
}